package com.example.demo.repository;

import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ImportExcelmapper {


    @Update(" <script>" +
            "create table ${sheetName} (${sheetName} varchar(100)," +
            "<foreach item='value' collection='list' separator='text,' close='text)'>" + "`" +
            "${value}" + "`" +
            "</foreach>" + "</script>")
    int createTable(@Param("sheetName") String sheetName, @Param("list") ArrayList<String> list);

    //@Insert("<script>" +
    //        "insert into ${sheetName} (" +
    //        "<foreach item='value' collection='list' separator=',' close=')'>" +"`"+
    //        "${value}"+"`" +
    //        "</foreach>" +
    //        "values (" +
    //        "<foreach item='item' collection='insert' separator=',' close=')'>" +
    //        "</script>")
    //int insertTable(@Param("sheetName") String sheetName,@Param("list") ArrayList<String> list,@Param("insert") ArrayList<String> insert);
    //
    @Insert(" <script>" +
            "insert into ${sheetName} (<foreach item='value' collection='list' separator=',' close=')'>`${value}`</foreach> " +
            "values " +
            "(<foreach item='item' collection='insert' separator=',' close=')' >#{item}</foreach>" +
            "</script>")
    int insertTable(@Param("sheetName") String sheetName, @Param("list") ArrayList<String> list, @Param("insert") String[] insert);

}
